#encoding: utf-8
from flask import Flask,session
import os

app = Flask(__name__)
#app.config['SECRET_KEY'] = os.urandom(24)
app.config['SECRET_KEY'] = 'xxxxxxxxxxxxxxxxxxxxxxxx'


@app.route('/')
def hello_word():
    session['username'] = 'xiaokang'
    return 'hello world'

@app.route('/get/')
def get():
    if session.get('username'):
        return session.get('username')
    else:
        return '请登录'

@app.route('/delete/')
def delete():
    if session.get('username'):
        session.pop('username')
    return '已退出;SECRET_KEY:'+app.config['SECRET_KEY']

@app.route('/clear/')
def clear():
    if session.get('username'):
        session.clear()
    return '已退出'

if __name__ == '__main__':
    app.run(host="0.0.0.0", debug=True)